package com.wzp;

import java.nio.ByteBuffer;

/**
 * @author wangzhengpeng
 */
public class HelloDirectMemoryOutOfMemory {

    public static final int ONE_MB = 1024 * 1024 * 1024;

    public static int count = 1;

    public static void main(String[] args) {
        try {
            while (true) {
                ByteBuffer byteBuffer = ByteBuffer.allocateDirect(ONE_MB);
                count++;
            }
        } catch (Exception e) {
            System.out.println("Exception:instance created " + count);
            e.printStackTrace();
        } catch (Error error) {
            System.out.println("Error:instance created " + count);
            error.printStackTrace();
        }
    }
}
